fix: resolve Solana connect race condition causing WalletNotSelectedError#163
Open
fix: resolve Solana connect race condition causing WalletNotSelectedError#163
Conversation
a48be84 to
ad76558
Compare
…rror The previous implementation called select() and connect() synchronously, but connect() executed before React state updated from select(), causing WalletNotSelectedError. Now uses an effect to wait for wallet selection before initiating connection. Co-authored-by: Cursor <cursoragent@cursor.com>
ad76558 to
25c9f3a
Compare
adonesky1
commented
Feb 4, 2026
Comment on lines
2
to
13
| @@ -10,7 +9,6 @@ import { WalletModalProvider } from '@solana/wallet-adapter-react-ui'; | |||
| import type React from 'react'; | |||
| import { | |||
| createContext, | |||
| useCallback, | |||
Contributor
Author
There was a problem hiding this comment.
Unrelated cleanup 😅
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
WalletNotSelectedErrorbeing thrown when clicking "Connect (Solana)" without the extension installedselect()andconnect()calls in the Solana wallet adapterBefore
Screen.Recording.2026-02-04.at.2.49.38.PM.mov
After
Screen.Recording.2026-02-04.at.2.51.34.PM.mov
Problem
When connecting to Solana, the previous code called
select()followed immediately byconnect(). Sinceselect()triggers an async React state update,connect()was executing before the wallet was actually selected, causingWalletNotSelectedErrorto appear in the console.Solution
Use an effect-based approach that waits for the wallet to be selected before initiating the connection:
connectSolana()callsselect()and sets asolanaPendingConnectflaguseEffectwatches for when both the flag is set and the wallet becomes availableconnect(), ensuring proper sequencingTesting Steps
WalletNotSelectedErrorin console